<template>
  <div class="box1">
    <div class="bg">
      <!-- 头部 -->
      <div class="jiancha">
        <p>饿了么</p>
        <van-search class="jiansuo"
          v-model="serch"
          shape="round"
          background="rgb(103, 134, 219)"
          placeholder="请输入搜索关键词"
          input-align="center"
        />
      </div>
    </div>
    <!-- 轮播图 -->
    <van-swipe class="myswipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="(image, index) in images" :key="index">
        <img v-lazy="image" />
      </van-swipe-item>
    </van-swipe>
    <!-- 店铺列表 -->
    <div class="list">
      <p>猜你喜欢</p>
      <div class="like">
        <span>综合排序∨</span>
        <span>距离最近</span>
        <span>销量最高</span>
        <span>筛选</span>
      </div>
      <div class="youhui">
        <span>年货节热卖</span>
        <span>津贴联盟</span>
        <span>满减优惠</span>
        <span>品质联盟</span>
      </div>
      <div class="dpxx">
        <div class="item" v-for="(item, index) in arr" :key="index" >
        <div class="img">
        <img :src="item.picUrl" alt="">
        </div>
        <div class="text">
        <div class="name">{{ item.name }}</div>
        <div class="math">
        <span class="pingfen">★{{ item.wmPoiScore }}</span>
        <span class="yueshou">{{ item.monthSalesTip }}</span>
        </div>
        <div class="songcan">
        <div class="left">
        <span class="qisong">{{ item.minPriceTip }}</span>
        <span class="yuanjuli">远距离{{ item.shippingFeeTip }}</span>
        </div>
        <div class="right">
        <span class="time"> {{ item.deliveryTimeTip }}</span>
        <span class="juli"> {{ item.distance }}</span>
        </div>
        </div>
        <div class="pingjia">
        <span class="pj1">扬州炒饭帮帮的</span>
        <span class="pj2">海淀区销量第一</span>
        </div>
        <div class="jianmian">
        <span class="jm1" v-for="(item, index) in item.discounts2" :key="index">{{ item.info
        }}</span>
      </div>
       </div>
       </div>
    </div>
  </div>
   </div>
</template>

<script>
// 轮播图组件比较特殊 需再次导入
import Vue from "vue";
import { Lazyload } from "vant";
Vue.use(Lazyload);
// 导入请求函数地址
import { api_banner_list, api_shop_list } from "../ulits/api";
export default {
  data() {
    return {
      serch: "",
      images: [],
      arr: [],
    };
  },
  // methods() {},
  mounted() {
    // 发轮播图请求
    api_banner_list({}).then((res) => {
      console.log(res.data);
      res.data.list.forEach((element) => {
        this.images.push(element.bannerUrl);
      });
    });
    // 发店铺请求
    api_shop_list({}).then((res) => {
      console.log(res.data);
      res.data.list.forEach((element) => {
        this.arr.push(element);
      });
    });
  },
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
}
.box1{
  width: 100%;
  height: 100%;
}
.bg {
  background-color: rgb(103, 134, 219);
  height: 80px;
}
.jiancha p {
  font-size: 20px;
  color: white;
  font-size: 700;
  padding-left: 10px;
}
.jiansuo{
  margin: 10px auto;
  width: 80%;
}
.myswipe {
  margin: 10px;
  border-radius: 10px;
}
.myswipe img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
}
.myswipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  text-align: center;
}
.list {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 6px 10px ;
  overflow: auto;
}
.list p {
  font-size: 16px;
  font-weight: 700;
}
.list .like {
  display: flex;
  justify-content: space-between;
  margin: 6px 0px;
  font-size: 14px;
}
.list .like span{
  width: 80px;
  text-align: center;
}
.list .youhui {
  display: flex;
  justify-content: space-between;
  font-size: 12px;

}
.list .youhui span {
  text-align: center;
  line-height: 30px;
  border-radius: 5px;
  width: 80px;
  height: 30px;
  display: inline-block;
  background-color: #ddd;
}
.list .dpxx {
  flex: 1;
  overflow: auto;
  margin-top: 10px;
}
.list .dpxx .item img {
  width: 100%;
  height: 100%;
}
.list .item {
  display: flex;
  margin: 10px 0px;
}
.list .item .img {

  width: 100px;
  height: 100px;
  background-color: aqua;
}
.list .item .text {
  flex: 1;
  padding: 5px;

}
.text .name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 5px;
}
.text .math .pingfen {
  font-size: 14px;
  color: orangered;
  margin-right: 5px;

}
.text .math .yueshou {
  font-size: 14px;
}
.text .songcan {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.text .songcan span {
  margin-right: 5px;
}

.text .pingjia {
  margin-bottom: 5px;
}

.text .pingjia span {
  box-sizing: border-box;
  font-size: 12px;
  display: inline-block;
  background-color: #FFEEE0;
  color: #f15d1d;
  margin-right: 8px;
  padding: 0px 5px;
}

.text .jianmian span {
  box-sizing: border-box;
  font-size: 12px;
  display: inline-block;
  border: 1px solid red;
  border-radius: 5px;
  color: #f15d1d;
  margin-right: 5px;
  padding: 0px 5px;

}
</style>